﻿<Window x:Class="Demos.Puzzles.Polyominoes.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:polyominoes="clr-namespace:Demos.Puzzles.Polyominoes"
        Title="Polyominoes" Height="350" Width="600" Name="view">
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="25"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition Width="40"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <DockPanel Grid.Row="0" Grid.Column="1">
            <Grid DockPanel.Dock="Top" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition Width="100"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                
                <ComboBox Grid.Column="0" ItemsSource="{Binding ContenidoSelector}" Width="150"
                          SelectedIndex="{Binding TableroSeleccionado, UpdateSourceTrigger=PropertyChanged}"/>
                
                <Label Grid.Column="1" HorizontalAlignment="Center" FontWeight="Bold"
                       Content="{Binding Titulo, UpdateSourceTrigger=PropertyChanged}">
                </Label>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="2">
                    <Button Width="20" Command="{Binding DisminuirCommand}">-</Button>
                    <Label>N =</Label>
                    <Label Content="{Binding NView, UpdateSourceTrigger=PropertyChanged}"></Label>
                    <Button Width="20" Command="{Binding AumentarCommand}">+</Button>
                </StackPanel>
            </Grid>
            
            <Slider Orientation="Horizontal" DockPanel.Dock="Bottom" Margin="5"
                    Minimum="1" Maximum="20" IsSnapToTickEnabled="True"
                    IsEnabled="{Binding Bloqueo, UpdateSourceTrigger=PropertyChanged}"
                    Value="{Binding Columnas, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
            </Slider>

            <Border DockPanel.Dock="Left" BorderBrush="DarkGray" BorderThickness="1" Name="TableroBd">
                <Grid>
                    <polyominoes:Visor Tablero="{Binding Tablero, UpdateSourceTrigger=PropertyChanged}"
                                    DataContext="{Binding ElementName=view, Path=DataContext}"
                                    VerticalAlignment="Center"/>
                    <polyominoes:Editor Tablero="{Binding Tablero, UpdateSourceTrigger=PropertyChanged}"
                                    FilaSeleccionada="{Binding FilaSeleccionada, UpdateSourceTrigger=PropertyChanged, Mode=OneWayToSource}"
                                    ColumnaSeleccionada="{Binding ColumnaSeleccionada, UpdateSourceTrigger=PropertyChanged, Mode=OneWayToSource}"
                                    DataContext="{Binding ElementName=view, Path=DataContext}"
                                    Visibility="{Binding VerEditor, UpdateSourceTrigger=PropertyChanged}"
                                    VerticalAlignment="Center"/>
                </Grid>
            </Border>
        </DockPanel>

        <Slider Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" Margin="5"
                Orientation="Vertical" DockPanel.Dock="Right" Height="{Binding ElementName=TableroBd, Path=ActualHeight}"
                Minimum="1" Maximum="20" IsSnapToTickEnabled="True" 
                IsEnabled="{Binding Bloqueo, UpdateSourceTrigger=PropertyChanged}"
                Value="{Binding Filas, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
        </Slider>

        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
            <ComboBox Grid.Column="0" ItemsSource="{Binding ContenidoSelectorAlgoritmos}" Width="100" Margin="0,0,20,0"
                          SelectedIndex="{Binding AlgoritmoSeleccionado, UpdateSourceTrigger=PropertyChanged}"/>
            <Button Width="60" Command="{Binding GuardarCommand}"  Margin="0,0,5,0">Guardar</Button>
            <Button Width="60" Command="{Binding CargarCommand}">Cargar</Button>
            <Button Grid.Column="2" Width="60" Command="{Binding RunCommand}" Margin="5,0,0,0">Resolver</Button>
            <Button Grid.Column="2" Width="60" Command="{Binding AñadirFichasCommand}" Margin="5,0,0,0"
                    Visibility="{Binding VerEditor, UpdateSourceTrigger=PropertyChanged}"
                    Content="{Binding ContenidoBotonFichas, UpdateSourceTrigger=PropertyChanged}">
            </Button>
        </StackPanel>
        

    </Grid>
</Window>
